<?php
/**
 * 2014年9月16日08:54:11
 * Author:cgp
 * TODO::显示转分销订单
 */
ob_start();
include("common/header.html");
include("common/left.html");
$out_html=ob_get_contents();
ob_end_clean();
include("common/page.php");
include("class/OrderRecord.php");
include("class/ProOrder.php");
include("class/SimpleExcel.class.php");
include("class/SoapInit.class.php");
$atype= 'sale';// 导出文件名判断条件

$s = SoapInit::GetSoapInside();
$memberID=$_SESSION['sid'];
//如果是admin，就不要下拉
$hideList = false;
if($_SESSION['memberID']==1){
    $hideList = true;
}
else{
    // 获取对应的分销商
    if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors' || $_REQUEST['tjs']==4){
        include 'getDistors.php';
        // 集团账号获取供应商和分销商
        if($_SESSION['dtype']==7){
            $DistorsNames = getAll($GLOBALS['le'],$_SESSION['sid']);
            //print_r($DistorsNames);
        }else{
            $DistorsNames = getRetail($GLOBALS['le']);
        }
        // print_r($DistorsNames);

        // 异步获取对应的分销商
        if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors'){
            echo json_encode(array('s'=>'success','d'=>$DistorsNames));
            exit;
        }
    }
}
$dTypeName = '分销商';

$str="select id,dname from pft_member where dtype=0";
$anames=array();
$GLOBALS['le']->query($str);
while($row=$GLOBALS['le']->fetch_assoc()){
    $anames[$row['id']]=$row['dname'];
}
//print_r($anames);
$pOrder     = saleProOrderObject($memberID, $s, 'TRANS');
$v['title'] = "分销订单";
$v['title2'] = "直销订单";
$currentPage= $_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize   = $_REQUEST['pageSize']?$_REQUEST["pageSize"]:15;
// 导出订单设置
if(isset($_REQUEST['act']) && $_REQUEST['act']=="Export"){
    $currentPage=1;
    $pageSize=99999;
    set_time_limit(1800);
}
$r = $pOrder->_orderlist($currentPage,$pageSize);

$fids=array();
$orderCount = $ticketCount = $allMoney = 0;// 订单统计信息
foreach($r as $key=>$row){
    if($r[$key]['mainOrder']->UUlid!=72){
        if($r[$key]['mainOrder']->UUstatus!=1){
            $r[$key]['mainOrder']->UUordertel=substr_replace((string)$r[$key]['mainOrder']->UUordertel,"****",3,4);
        }
    }

    $fids[]=(string)$row['mainOrder']->UUbuyid;
    // 统计订单信息
    $orderCount++;
    $ticketCount+=(string)$row['mainOrder']->UUtnum;
    $allMoney+=((int)$row['mainOrder']->UUtotalmoney)/100;
}

if($fids){
    $sel="select id,dname from pft_member where id in (".implode(",",$fids).")";
    $fnames=array();
    $GLOBALS['le']->query($sel);
    while($row=$GLOBALS['le']->fetch_assoc()){
        $fnames[$row['id']]=$row['dname'];
    }
}
include("loadExcel_simple.php");
echo $out_html;
// 判断订单是否为主订单  true为主订单
function isMainOrder($field){
    return ($field!=0 ) ? true:false;
}
// 复票订单主订单
function echoMainOrder($obj){
    return ((String)$obj->UUconcat_id=='main') ? (String)$obj->UUordernum:(String)$obj->UUconcat_id;
}
$count=$pOrder->orderlistTotal();
$str="select account from pft_member where id=$memberID";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$account=$GLOBALS['le']->f("account");
$arr_salerid=array(501610,501612);
$uuStatus = array(0=>"未使用",1=>"<em class='green'>已使用</em>",2=>"已过期",3=>"<em class='red'>已取消</em>",4=>"被替代",5=>"被修改",6=>"已撤销",7=>"部分使用");
// 不显示分销商列
$showDtrArr = array(2223);
$showDtr = true;
if(in_array($_SESSION['sid'], $showDtrArr)){
	$showDtr = false;
}
// print_r($r);
include("tpl/orderLists_trans2.tpl");
include("common/footer.html");

?>